﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>用户登陆</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<style type="text/css">
		html, body{
			margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
			font-size: 14px; line-height: 14px;
		}

		body {
			/* 设置背景图片 */
			background-image: url("images/bg.jpg");
			/* 背景图片不平铺 */
			background-repeat: no-repeat;
			/* 背景图片全屏 */
			background-size: cover;
			/* 背景图片固定，内容滚动时背景不跟随滚动 */
			background-attachment: fixed;
		}

		.head {
			width: 100%; margin:0px; padding: 5px 10px; background-color: #1b6d85;
			font-size: 15.21px; line-height: 22px; color: #FFFFFF;
		}

		.container {
			width: 100%;
			height: 90%;
			display: flex; justify-content: center; align-items: center;
		}

		.submit {
			width: 260px; padding: 10px 0; background-color: #1b6d85; color: #FFFFFF;
			border: #2d5f8b 1px solid;
		}
	</style>
</head>
<body>
<h3 class="head">检验检测现场受理系统</h3>
<div class="container">
	<form name="form">
		<table style="width:300px; padding: 30px 40px 20px 40px; background-color: #F0F8FF;">
			<tr>
				<td style="width:80px; height: 50px; text-align: right;">用户名：</td>
				<td style="width:200px; text-align: right;">
					<input type="text" name="userName" id="userName" style="width: 190px; line-height: 24px;" maxlength="20" />
				</td>
			</tr>
			<tr>
				<td style="height: 50px; text-align: right;">密　码：</td>
				<td style="text-align: right;">
					<input type="password" name="userPass" id="userPass" style="width: 190px; line-height: 24px;" maxlength="20" />
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center" style="height: 70px; text-align: right;">
					<input type="button" value="立即登陆" class="submit" onclick="login()" />
				</td>
			</tr>
		</table>
	</form>
</div>

<script type="text/javascript">
	window.onload = function () {
		document.getElementById("userName").focus();
		document.onkeydown = function (e) {
			var theEvent = window.event || e;
			var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
			if (code == 13) {
				login();
			}
		}
	};
	document.write('<script src="js/jquery.min.js" type="text/javascript"></sc' + 'ript>');
	document.write('<script src="js/md5.min.js" type="text/javascript"></sc' + 'ript>');

	function login() {
		var userName = document.form.userName.value;
		userName = $.trim(userName);
		var userPass = document.form.userPass.value;
		if(userName == "" || userName == null) {
			alert("用户名和密码不能为空！");
			document.form.userName.focus();
			return;
		}
		if(userPass == "" || userPass == null) {
			alert("用户名和密码不能为空！");
			document.form.userPass.focus();
			return;
		}

		$.ajax({
			url: "/sign/login/" + userName + "/" + md5(userPass),
			type: 'post',
			contentType: "application/json;charset=UTF-8",
			cache: false,
			success: function (obj) {
				if(obj) {
					if(obj.code == "200") {
						top.location.href = "index.html";
					} else {
						alert("用户名或密码错误！");
						return;
					}
				}
			},
			error: function (jqXHR, textStatus, errorThrown) {
				alert(jqXHR.responseText);
				CloseWindow();
			}
		});
	}
</script>

</body>
</html>